Objects Reference

mesh::ray_intersect

Prototype

int ray_intersect(vector& ro,vector& rd,vector& ip,float& dist,float rad=0.0f)

Parameters

Parameter Type Description
ro vector& ray origin
rd vector& ray direction
ip vector& intersection point
dist float& intersection distance
rad float& collision radius

Return Value

Returns TRUE if an intersection is found, FALSE for no intersection.

Remarks

This function computes the ray intersection with the mesh. 
If an intersection is found, ip will be set to the intersection point, dist will be set to the distance from the ray origin (ro) to the indersection point (ip). 
If rd is normalized, the dist value will be in scene units, if not, if will be the distance divided by the ray direction (rd) length.
The rad parameter sets the collision radius. If >0, the collision will be tested for a sphere with radius rad.
All faces from the mesh are tested for intersection and the closest intersection is returned. The ray_intersect_test function is a faster version that returns the first intersection (good for when you just need to know if there is an intersection and do not care where).